home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / tcqbsnip.zip / GETARY.BAS < prev    next >
BASIC Source File  |  1997-06-20  |  878b  |  28 lines

  1. ' GETARY.BAS
  2. ' by Tika Carr
  3. '
  4. ' Donated to the public domain
  5. ' No warranties or guarantees are expressed or implied.
  6. '
  7. ' Purpose: Calculates maximum array size for GET/PUT
  8.  
  9. DECLARE FUNCTION GetAry! (x1%, y1%, x2%, y2%, mode%)
  10.  
  11. DEFINT A-Z
  12.  
  13. 'This would set up enough space to hold a sprite that's taken from:
  14. 'Upper left: 100, 100  Lower right: 145, 130
  15. 'Any errors may be due to the fact the array is too large to hold.
  16. 'try using '$DYNAMIC and loading qb with the /ah switch.
  17.  
  18. 'REDIM Buffer(1 TO GetAry!(100, 100, 145, 130, 13))
  19.  
  20. FUNCTION GetAry! (x1%, y1%, x2%, y2%, mode%)
  21. IF mode% = 1 THEN bpp = 2: pln = 1
  22. IF mode% = 2 OR mode% = 11 THEN bpp = 1: pln = 1
  23. IF (mode% > 6 AND mode% < 10) OR mode% = 12 THEN bpp = 1: pln = 4
  24. IF mode% = 13 THEN bpp = 8: pln = 1
  25. GetAry = 4 + INT(((x2% - x1% + 1) * bpp + 7) / 8) * pln * ((y2% - y1%) + 1)
  26. END FUNCTION
  27.  
  28.